#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <adminmenu>
#include <geoip>

#define PLUGIN_VERSION "1.0.0"

enum struct Player {
	char SteamId[32];
}

Player	g_ePlayer[MAXPLAYERS + 1];

bool Pass;

public Plugin myinfo =
{
	name = "玩家进服显示地区IP与SteamId",
	author = "Mandysa.",
	description = "玩家进服显示地区IP与SteamId",
	version = PLUGIN_VERSION,
	url = "qq3063276667"
} 

public void OnMapStart()
{
	Pass = true;
	CreateTimer(18.0, PASS);
}

public Action PASS(Handle timer)
{
	Pass = false;
	return Plugin_Handled;
}

public void OnClientPutInServer(int client)
{
	char ClientIP[16];
	char Continent[32];
	char country[45];
	char Region[32];
	char City[32];

	if(!Pass)
	{
		if(!IsFakeClient(client))
		{
			GetClientIP(client, ClientIP, 16);
			GetClientAuthId(client, AuthId_Steam2, g_ePlayer[client].SteamId, sizeof Player::SteamId);
		
			
			if(GeoipContinent(ClientIP, Continent, 32))
			if(GeoipCountry(ClientIP, country, 45))
			if(GeoipRegion(ClientIP, Region, 32))
			if(GeoipCity(ClientIP, City, 32))
			{
				PrintToChatAll("\x04[提示]\x03%N\x04 加入了服务器 \x05IP:\x04%s 来自国家/地区:\x05%s %s %s %s, \x04SteamId:\x05%s ", client, ClientIP, Continent, country, Region, City, g_ePlayer[client].SteamId);
			}
			else
			{
				PrintToChatAll("\x04[提示]\x03%N\x04 加入了服务器 \x05IP:\x04%s 国家/地区:\x05Error SteamId:\x05%s -by Mandysa", client, ClientIP, g_ePlayer[client].SteamId);
			}
		}
	}
	return;
}